home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / alib / csup / rexx_support / rexx.i < prev    next >
Encoding:
Text File  |  1994-02-17  |  9.3 KB  |  227 lines

  1. * === rexx/rexx.i ======================================================
  2. *
  3. * Copyright (c) 1986-1990 by William S. Hawes.  All Rights Reserved.
  4. *
  5. * ======================================================================
  6. * Main include file for Rexx interpreter.  Includes definitions for data
  7. * structures and flags used for parsing and execution.
  8.  
  9.          IFND     REXX_REXX_I
  10. REXX_REXX_I       EQU   1
  11.  
  12.          IFND     REXX_STORAGE_I
  13.          INCLUDE "rexx/storage.i"
  14.          ENDC
  15.  
  16. * Limit constants
  17. TEMPBUFF    EQU   1000                 ; initial size of global work buffer
  18. MAXLEN      EQU   65535                ; maximum length of strings
  19. MAXFNLEN    EQU   64                   ; maximum filing system name length
  20. RDTEST      EQU   80                   ; characters to read to test a file
  21.  
  22. ENV_MAX_DIGITS EQU 14                  ; maximum numeric digits
  23.  
  24. * Character definitions
  25. EOFCHAR     EQU   -1                   ; EOF flag
  26. NULL        EQU   0           
  27. NEWLINE     EQU   $0A                  ; 'newline' character
  28. BLANK       EQU   ' '                  ; ASCII blank
  29. DQUOTE      EQU   '"'                  ; ASCII double quote
  30. QUOTE       EQU   $27                  ; ASCII single quote
  31. PERIOD      EQU   '.'                  ; ASCII period
  32.                               
  33. LOWERBIT    EQU   5                    ; ASCII lowercase bit
  34. ASCIIBIT    EQU   7                    ; non-ASCII bit (sign bit)
  35.  
  36. * Special character codes
  37. SPC_COMMA   EQU   ','
  38. SPC_SEMI    EQU   ';'
  39. SPC_COLON   EQU   ':'
  40. SPC_OPEN    EQU   '('
  41. SPC_CLOSE   EQU   ')'
  42.  
  43. * String types for classification
  44. STR_ASCII   EQU   1                    ; ASCII string
  45. STR_HEX     EQU   2                    ; HEX digit string
  46. STR_BINARY  EQU   3                    ; BINARY digit string
  47.  
  48.          ; The Token structure ...
  49.  
  50.          STRUCTURE Token,0
  51.          LONG     t_Succ               ; successor token
  52.          LONG     t_Pred
  53.          UBYTE    t_Type               ; token type
  54.          UBYTE    t_Flags              ; attribute flag bits
  55.          UWORD    t_Offset             ; position or keyword code
  56.          LONG     t_Data               ; opcode or string structure
  57.          LABEL    t_SIZEOF             ; size: 16 bytes
  58.  
  59. * Defined fields
  60. TOFFSET  EQU      t_Offset             ; offset in clause
  61. TKEYCODE EQU      t_Offset             ; keyword code (2-byte)
  62. TDATA    EQU      t_Data
  63. TSTRING  EQU      t_Data               ; string structure (4-byte)
  64. TOPCODE  EQU      t_Data+3             ; opcode (1-byte)
  65.  
  66. * Token type definitions ...
  67. TTB_SYMBOL  EQU   4                    ; symbol token type bit
  68. TTF_SYMBOL  EQU   1<<TTB_SYMBOL
  69.  
  70. T_STRING    EQU   1                    ; String Token
  71. T_OPERATOR  EQU   2                    ; Operator Token
  72. T_COMMA     EQU   3                    ; Special Character Token: ','
  73. T_LABEL     EQU   4                    ; Special Character Token: ':'
  74. T_OPEN      EQU   5                    ; Special Character Token: '('
  75. T_CLOSE     EQU   6                    ; Special Character Token: ')'
  76. T_END       EQU   7                    ; Special Character Token: ';'
  77. T_TERM      EQU   8                    ; expression terminator
  78. T_FUNCTION  EQU   9                    ; function awaiting evaluation
  79. T_SYMFIXED  EQU   TTF_SYMBOL!12        ; fixed symbol
  80. T_SYMVAR    EQU   TTF_SYMBOL!13        ; variable symbol
  81. T_SYMCMPD   EQU   TTF_SYMBOL!14        ; compound symbol
  82. T_SYMSTEM   EQU   TTF_SYMBOL!15        ; stem symbol
  83.  
  84. * TSTMASK is a bitmask indicating whether a token may carry a string object.
  85. * If it can, then the bit corresponding to the token type is set.
  86. TSTMASK     EQU   (1<<1)!(1<<7)!(1<<8)!(1<<28)!(1<<29)!(1<<30)!(1<<31)
  87.  
  88. * Token flag bit definitions
  89. TFB_FUNCDEF EQU   0                    ; token defines a function?
  90. TFB_THEN    EQU   1                    ; 'THEN' symbol?
  91. TFB_BLANK   EQU   2                    ; blank (operator) token?
  92. TFB_QUOTED  EQU   3                    ; quoted argument string?
  93. TFB_EQUALS  EQU   4                    ; '=' sign?
  94. TFB_PERIOD  EQU   5                    ; '.' symbol?
  95. TFB_ASSIGN  EQU   6                    ; an assignment symbol?
  96. TFB_NOSTR   EQU   7                    ; don't recycle string?
  97.  
  98.          ; Clause structure ...
  99.  
  100.          STRUCTURE Clause,0
  101.          APTR     c_Succ               ; successor
  102.          APTR     c_Pred               ; predecessor
  103.          UBYTE    c_Type               ; clause classification
  104.          UBYTE    c_Flags              ; attribute bits
  105.          UWORD    c_Count              ; number of tokens
  106.          APTR     c_Link               ; token pointer
  107.  
  108.          UWORD    c_SrcLine            ; source line number
  109.          UWORD    c_Len                ; length of clause
  110.          ULONG    c_Keys               ; instruction code
  111.          ULONG    c_SrcPos             ; source position
  112.          ULONG    c_NextPos            ; "next" clause position
  113.  
  114.          APTR     cTL_Head             ; first token (list header)
  115.          APTR     cTL_Tail
  116.          APTR     cTL_TailPred         ; last token
  117.          APTR     c_Name               ; string structure
  118.          LABEL    c_SIZEOF             ; size: 48 bytes
  119.  
  120. * Defined fields
  121. CSECKEYS EQU      c_Keys+2
  122. CLINK    EQU      c_Link
  123.  
  124. * Clause type codes
  125. C_NULL      EQU   1                    ; Null Clause
  126. C_LABEL     EQU   2                    ; Label Clause
  127. C_ASSIGN    EQU   3                    ; Assignment Clause
  128. C_INSTRUCT  EQU   4                    ; Instruction Clause
  129. C_COMMAND   EQU   5                    ; Command Clause
  130. C_ARGLIST   EQU   6                    ; argument list header
  131. C_ERROR     EQU   $FF                  ; Error flag
  132.  
  133. * Clause attribute flag bit definitions
  134. CFB_SYMBOL  EQU   0                    ; first token a symbol
  135. CFB_SIMPLE  EQU   1                    ; expressions processed
  136. CFB_NULLEXPR EQU  2                    ; expression was null
  137. CFB_FINAL   EQU   3                    ; final scan
  138. CFB_PARSED  EQU   4                    ; fully parsed
  139. CFB_ANYFUNC EQU   5                    ; any functions?
  140. CFB_CACHED  EQU   7                    ; clause cached
  141.  
  142. * The flag form of the clause attributes
  143. CFF_SYMBOL  EQU   1<<CFB_SYMBOL
  144. CFF_SIMPLE  EQU   1<<CFB_SIMPLE
  145. CFF_NULLEXPR EQU  1<<CFB_NULLEXPR
  146. CFF_FINAL   EQU   1<<CFB_FINAL
  147. CFF_PARSED  EQU   1<<CFB_PARSED
  148. CFF_ANYFUNC EQU   1<<CFB_ANYFUNC
  149. CFF_CACHED  EQU   1<<CFB_CACHED
  150.  
  151.          ; The SourceSegment structure is used to maintain the Source Array,
  152.          ; Labels Array, and Source Line Array.  The data fields may be
  153.          ; either an integer value or a pointer to a string structure.
  154.          ; The allocated size is (4 + sCount*4).
  155.  
  156.          STRUCTURE SourceSegment,0
  157.          LONG     sCount               ; number of entries
  158.          APTR     sSeg                 ; array of pointers to segments
  159.          LABEL    s_SIZEOF             ; size: 8 bytes
  160.  
  161. SEGSHIFT EQU      16                   ; shift for segment
  162. SEGMASK  EQU      $0000FFFF            ; mask for offset
  163.  
  164.          ; The control range structure
  165.  
  166.          STRUCTURE Range,0
  167.          APTR     r_Succ               ; next range
  168.          APTR     r_Pred
  169.          UBYTE    r_Type               ; range type
  170.          UBYTE    r_Flags              ; control flags ...
  171.          UWORD    r_Pad
  172.          LONG     r_Value              ; node pointer
  173.  
  174.          UWORD    r_Action             ; various uses ...
  175.          UWORD    r_Test               ; test expression result
  176.          LONG     r_Count              ; iteration count
  177.          ULONG    r_SrcPos             ; source offset of activating line
  178.          ULONG    r_NextPos            ; source position after range
  179.  
  180.          APTR     r_Segment            ; source segment
  181.          APTR     r_Index              ; index variable or result
  182.          APTR     r_TO                 ; limit expression result
  183.          APTR     r_BY                 ; increment expression result
  184.          LABEL    r_SIZEOF             ; size: 48 bytes
  185.  
  186. RCOMP    EQU      r_Action+1           ; comparison operator
  187.  
  188. * Control range type codes
  189. NRANGE_DO      EQU   1                 ; 'DO' range
  190. NRANGE_IF      EQU   2                 ; 'IF' range
  191. NRANGE_SELECT  EQU   3                 ; 'SELECT' range
  192. NRANGE_INTERP  EQU   4                 ; 'INTERPRET' instruction
  193.  
  194. * Control range flag bit definitions
  195. NRFB_ACTIVE    EQU   0                 ; execute the range?
  196. NRFB_INIT      EQU   1                 ; initialized yet?
  197. NRFB_ITERATE   EQU   2                 ; iterative range?
  198. NRFB_THEN      EQU   3                 ; 'THEN' clause?
  199. NRFB_ELSE      EQU   4                 ; 'ELSE' or 'OTHERWISE' clause?
  200. NRFB_DEBUG     EQU   5                 ; 'debug' mode?
  201. NRFB_BRANCH    EQU   6                 ; branch taken?
  202. NRFB_FINISH    EQU   7                 ; range finished?
  203.  
  204. * Control range flags
  205. NRFF_ACTIVE    EQU   1<<NRFB_ACTIVE
  206. NRFF_INIT      EQU   1<<NRFB_INIT
  207. NRFF_ITERATE   EQU   1<<NRFB_ITERATE
  208. NRFF_THEN      EQU   1<<NRFB_THEN
  209. NRFF_ELSE      EQU   1<<NRFB_ELSE
  210. NRFF_FINISH    EQU   1<<NRFB_FINISH
  211.  
  212.          ; The StacK structure is used to simulate stack operations,
  213.          ; which actually use doubly-linked lists.
  214.  
  215.          STRUCTURE StacK,0
  216.          APTR     skHead               ; first entry
  217.          APTR     skTail
  218.          APTR     skTailPred           ; last entry
  219.          WORD     skPad                ; not used
  220.          WORD     skNum                ; number of elements stacked
  221.          LABEL    skSIZEOF             ; size: 16 bytes
  222.  
  223. STACKTOP EQU      skHead
  224. STACKBOT EQU      skTailPred
  225.  
  226.          ENDC
  227.